package com.springboot.web;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/3/7.
 */


@RestController
@Component
public class HomeController {

    @Value("${com.didispace.blog.name}")
    private String name;

    @Value("${com.didispace.blog.title}")
    private String title;

    @RequestMapping("/")
    public String hello(){
        return "hello world";
    }

    @RequestMapping("/getHome")
    public Map<String,Object> getDemo(){
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("key",name);
        map.put("name",title);
        map.put("name1","nkfdjkfkfs434344");
        map.put("name2","nkfdjkf32323kfs");
        return map;
    }

    @RequestMapping("/cserr")
    public String cserr() throws Exception{
        throw new Exception("发生错误");
    }
}
